#pragma once

#include "effectbase.h"
#include "commonshape.h"
#include "videoeffect.h"
#include <osg\NodeCallback>

namespace VrDataCore
{
	class VideoUpdateCallback;

	class VRDATACORE_EXPORT HudVideoEffect:public EffectBase
	{
	public:
		HudVideoEffect();
	protected:
		~HudVideoEffect();
		virtual void createDrawable();
		osg::ref_ptr<VideoEffect>					_ve;
		QString									_videofile;
		osg::ref_ptr<VideoUpdateCallback>			_videoUpdateCallback;
		double									_videoLength;
		osg::Timer_t								_startT;
	public:
		virtual void buildPropertyMap();
		virtual void apply(CoreBase::ActorBase* actor);
		virtual void unApply(CoreBase::ActorBase* actor);
		void setVideoFileName(QString f);
		QString getVideoFileName();
		void callback();
	};

	class VideoUpdateCallback : public osg::NodeCallback
	{
	public:
		VideoUpdateCallback(HudVideoEffect* ve) 
		{
			_ve = ve ;
		}
		~VideoUpdateCallback() {} ;
		virtual void operator()( osg::Node* node, osg::NodeVisitor* nv)
		{
			if(_ve)
				_ve->callback();
		}
	private:
		HudVideoEffect*				_ve;
	} ;
}